<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"  xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head th:replace="_header_include::frag(~{::title},~{},~{})">
    <title>后台管理系统</title>
    <style>
        button a{color:#fff!important;}
    </style>
</head>
<body>
<div id="clueManage" class="clueManage mainPadding" style="display: none;">  
    <el-breadcrumb separator="/" class="elBreadcrumb marginB20">
        <el-breadcrumb-item>Home</el-breadcrumb-item>
        <el-breadcrumb-item>财务管理</el-breadcrumb-item>
        <el-breadcrumb-item>对账结算确认</el-breadcrumb-item>
    </el-breadcrumb>
    
    <el-row class="marginB20">
    		<el-button type="primary" @click="dialogFormVisible = true"><i class="el-icon-menu"></i>选择列</el-button>
    		<!--<shiro:hasPermission name="financing:reconciliationConfirmManager:reconciliation">-->
		        <el-button type="success" @click="reconciliationConfirm">对账确认</el-button>
		    <!--</shiro:hasPermission>-->
    		<!--<shiro:hasPermission name="financing:reconciliationConfirmManager:settlement">-->
		        <el-button type="warning" @click="settlementConfirm">结算确认</el-button>
		    <!--</shiro:hasPermission>-->
		    <el-button type="success" @click="down">下载结算单</el-button>
		    <!--<shiro:hasPermission name="financing:reconciliationConfirmManager:export">-->
	            <el-button type="warning" @click="exportFun"><i ></i>导出签约数据</el-button>
	        <!--</shiro:hasPermission>-->
	  </el-row>
    <div class="mainSearchBg">        
        <div class="mainSearchFormBox">
    	      <el-form :inline="true" :model="searchForm" class="demo-form-inline mainSearchForm" ref="searchForm"> 
      				  <el-form-item label="商务大区:"  prop="busAreaId">
      				    <el-select v-model="searchForm.busAreaId" clearable filterable  placeholder="商务大区" @change="changeBusArea" @clear="clearBusAreaList" >
      				      <el-option
      					      v-for="item in busAreaOptions"
      					      :key="item.id"
      					      :label="item.name"
      					      :value="item.id">
      					    </el-option>
      				    </el-select>
      				  </el-form-item>
      				  <el-form-item label="签单商务组:"  prop="busGroupId">
      				    <el-select v-model="searchForm.busGroupId" clearable filterable placeholder="签单商务组" @change="changeBusGroup" @clear="clearBusGroupList">
      				      <el-option
      					      v-for="item in busGroupOptions"
      					      :key="item.id"
      					      :label="item.name"
      					      :value="item.id">
      					    </el-option>
      				    </el-select>
      				  </el-form-item>
      				  <el-form-item label="签单商务经理:"  prop="busSaleId">
        				    <el-select v-model="searchForm.busSaleId" clearable filterable placeholder="签单商务经理">
          				      <el-option
          					      v-for="item in busSaleOptions"
          					      :key="item.id"
          					      :label="item.name"
          					      :value="item.id">
          					    </el-option>
        				    </el-select>
      				  </el-form-item>
                <el-form-item label="签约时间:">
                    <el-date-picker  v-model="searchForm.startTime" format="yyyy-MM-dd HH:mm" type="datetime" placeholder="选择日期"></el-date-picker>
                </el-form-item>
                <el-form-item label="—" class="widthauto">
                    <el-date-picker  v-model="searchForm.endTime" format="yyyy-MM-dd HH:mm" type="datetime" placeholder="选择日期"></el-date-picker>
                </el-form-item>
                <el-row v-show="isShow">
          				  <el-form-item label="处理状态:"  prop="status">
            				    <el-select v-model="searchForm.status" clearable placeholder="处理状态">
              				      <el-option
              					      v-for="item in statusOptions"
              					      :key="item.value"
              					      :label="item.name"
              					      :value="item.value">
              					    </el-option>
            				    </el-select>
          				  </el-form-item>
            			  <el-form-item label="签约项目:"  prop="signProjectId">
            			    <el-select v-model="searchForm.signProjectId" clearable filterable placeholder="签约项目">
            			      <el-option
            				      v-for="item in projectOptions"
            				      :key="item.id"
            				      :label="item.projectName"
            				      :value="item.id">
            				    </el-option>
            			    </el-select>
            			  </el-form-item>
              		  <el-form-item label="客户姓名:" prop="cusName">
              			  <el-input v-model="searchForm.cusName" placeholder="客户姓名" class="input-with-select"></el-input>
              		  </el-form-item>
                    <el-form-item label="付款时间:">
                        <el-date-picker  v-model="searchForm.payStartTime" format="yyyy-MM-dd HH:mm" type="datetime" placeholder="选择日期"></el-date-picker>
                    </el-form-item>
                    <el-form-item label="—" class="widthauto">
                        <el-date-picker  v-model="searchForm.payEndTime" format="yyyy-MM-dd HH:mm" type="datetime" placeholder="选择日期"></el-date-picker>
                    </el-form-item>
          				  <el-form-item label="电销事业部:"  prop="teleDeptId">
          				    <el-select v-model="searchForm.teleDeptId" clearable filterable  placeholder="电销事业部" @change="changeTeleDept" @clear="clearTeleDeptList">
          				      <el-option
          					      v-for="item in teleDeptOptions"
          					      :key="item.id"
          					      :label="item.name"
          					      :value="item.id">
          					    </el-option>
          				    </el-select>
          				  </el-form-item>
          				  <el-form-item label="电销组:"  prop="teleGorupId">
          				    <el-select v-model="searchForm.teleGorupId" clearable filterable  placeholder="电销组" @change="changeTeleGroup" @clear="clearTeleGroupList">
          				      <el-option
          					      v-for="item in teleGorupOptions"
          					      :key="item.id"
          					      :label="item.name"
          					      :value="item.id">
          					    </el-option>
          				    </el-select>
          				  </el-form-item>
          				  <el-form-item label="电销顾问:"  prop="teleSaleId">
          				    <el-select v-model="searchForm.teleSaleId" clearable filterable placeholder="电销顾问">
          				      <el-option
          					      v-for="item in teleSaleOptions"
          					      :key="item.id"
          					      :label="item.name"
          					      :value="item.id">
          					    </el-option>
          				    </el-select>
          				  </el-form-item>
            			  <el-form-item label="签约省份:"  prop="signProvince">
            			    <el-select v-model="searchForm.signProvince" clearable filterable  placeholder="签约省份">
            			      <el-option
            				      v-for="item in provinceOptions"
            				      :key="item.name"
            				      :label="item.name"
            				      :value="item.name">
            				    </el-option>
            			    </el-select>
            			  </el-form-item>
          				  <el-form-item label="付款类型:"  prop="payType">
          				    <el-select v-model="searchForm.payType" clearable placeholder="付款类型">
          				      <el-option
          					      v-for="item in payTypeOptions"
          					      :key="item.value"
          					      :label="item.name"
          					      :value="item.value">
          					    </el-option>
          				    </el-select>
          				  </el-form-item>
              		  <el-form-item label="客户联系方式:" prop="phone">
              			    <el-input v-model="searchForm.phone" placeholder="客户联系方式" class="input-with-select"></el-input>
              		  </el-form-item>
              		  <el-form-item label="结算单编号:" prop="statementNo">
              			    <el-input v-model="searchForm.statementNo" placeholder="结算单编号" class="input-with-select"></el-input>
              		  </el-form-item>
              		  <el-form-item label="签约单编号:" prop="signNo">
              			  <el-input v-model="searchForm.signNo" placeholder="签约单编号" class="input-with-select"></el-input>
              		  </el-form-item>
                </el-row>
                <div class="mainSearchBtnBox">
          		      <el-button icon="el-icon-search" type="primary" @click="searchTable()" class="searchBtn">搜索</el-button>
                    <!-- <el-button type="info" class="searchBtn">取消</el-button> -->
                    <span style="color: #5c6be8;cursor: pointer;margin:0 10px;" @click="toogleClick"><span v-if="isShow">收起</span><span v-else>展开更多</span><i :class="{'greycolor paddingL6 el-icon-arrow-up':isShow,'greycolor paddingL6 el-icon-arrow-down':!isShow}"></i></span>
                </div>
        	  </el-form>
        </div>
      	<div class="fs16 marginB20">已结算佣金总计：<span style="color:red;"> {{count}}元</span></div>
        <el-row>
            <el-table  ref="multipleTable" tooltip-effect="dark" border  @selection-change="handleSelectionChange"
                style="width: 100%"  :data="dataTable" >
               <el-table-column align="center" type="selection" label="全选" width="55"></el-table-column>
               <el-table-column align="center" type="index" label="序号" width="55"></el-table-column>
               
               <el-table-column align="center" :key="item.fieldCode" :prop="item.fieldCode" :label="item.displayName" :width="item.width" v-for="(item,key,index) in tableColums" v-if="item.fieldCode == 'isDoubt'">
    	               <template slot-scope="scope">
               		  	<div v-if="scope.row.isDoubt === 1">
                            <el-button type="text" size="small" @click="viewDoubt(scope.row)">
                            	查看疑意
                            </el-button>
                        </div>
                    </template>
    	        </el-table-column>
    	        <el-table-column align="center" :key="item.fieldCode" :prop="item.fieldCode" :label="item.displayName" :width="item.width"
    	         v-else-if="item.fieldCode == 'statementNo'">
    	               <template slot-scope="scope">
    	               <div v-if="scope.row.status !='驳回商务'  && scope.row.status !='未提交对账'">
    	               	<a :href="'/financing/balanceaccount/settleAccounts?payDetailId='+scope.row.payId+''" target="_blank" class="blueColorBtn">{{scope.row.statementNo}} </a>
    	               </div>
    	           <div v-else-if="scope.row.status =='驳回商务' || scope.row.status =='未提交对账'">
    	               	<a style="color:#222">{{scope.row.statementNo}} </a>
    	               </div>
    	               
                    </template>
    	        </el-table-column>
                <el-table-column align="center" :key="item.fieldCode" :prop="item.fieldCode" :label="item.displayName" :width="item.width" v-else-if="item.fieldCode == 'showReviewImages'">
                    <template slot-scope="scope">
                        <div v-if="scope.row.showReviewImages === 1 ">
                            <el-button type="text" size="small" @click="showReviewImageClick(scope.row)">点击查看<span style="color:red;">({{scope.row.reviewImagesNum}})</span> </el-button>
                        </div>
                    </template>
                </el-table-column>
                <el-table-column align="center" :key="item.fieldCode" :prop="item.fieldCode" :label="item.displayName" :width="item.width"
    	         	v-else>
    	        </el-table-column>
            </el-table>
            <table-pagination v-if="paginationShow" :pager="pager" @change="searchTable"></table-pagination>
        </el-row>
    </div>
    <!--查看疑意-->
    <el-dialog title="查看疑意" :visible.sync="viewDoubtVisable" width="50%" v-dialog-drag>
        <template>
            <el-form :model="viewDoubtForm" ref="viewDoubtForm">
                <el-form-item label="" :required="true">
                    <div class="lineFeed">{{viewDoubtForm.doubtRemark}}</div>
                </el-form-item>
            </el-form>
        </template>
    </el-dialog>
    <!-- 自定义列     -->
    <el-dialog title="自定义列" :visible.sync="dialogFormVisible" class="elCheckboxGroup">
	  <el-form :model="form">	    
		  <el-form-item label="" prop="type">
		    <el-checkbox-group v-model="form.type">
		      <el-checkbox :label="item.sortNum+'_'+item.fieldCode+'_'+item.displayName+'_'+item.id+'_'+item.width"  name="type" :key="item.fieldCode"  v-for="(item,index) in  allTableColums ">
		          {{item.displayName}}
		      </el-checkbox>		  
		     </el-checkbox-group>
		  </el-form-item>	    
	  </el-form>	  
	  <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="confirmColumn">确 定</el-button>      
	    <el-button @click="dialogFormVisible = false">取 消</el-button>
	  </div>
	</el-dialog>
    <!-- 查看签约/开店图片 -->
    <el-dialog title="签约/开店图片" :visible.sync="showReviewImagesDialog" width="1000px" >
        <el-table ref="multipleTable" :data="tableDataC1" tooltip-effect="dark" style="width: 100%" border  v-loadi>
            <el-table-column align="center" type="index" width="55" label="序号"></el-table-column>
            <el-table-column prop="uploadUserName" label="上传人姓名" align="center"></el-table-column>
            <el-table-column prop="uploadTime" label="上传时间" align="center"></el-table-column>
            <el-table-column prop="fileName" label="文件名称" align="center"></el-table-column>
            <el-table-column label="操作" align="center">
                <template slot-scope="scope">
                    <el-button size="mini" type="text" @click="handleOperateFn(scope.$index, scope.row)">
                        {{scope.row.fileType !=="jpg" && scope.row.fileType !=="png" && scope.row.fileType !=="jpeg" &&
                        scope.row.fileType !=="gif" && scope.row.fileType !=="bmp"? '下载录音':'查看图片'}}
                    </el-button>
                </template>
            </el-table-column>
            <el-table-column prop="delStatus" label="删除状态" align="center">
                <template slot-scope="scope">
                    <div v-if="scope.row.delStatus === 0">未删除</div>
                    <div v-else-if="scope.row.delStatus ===1" class="redcolor">已删除</div>
                </template>
            </el-table-column>
        </el-table>
    </el-dialog>
    <!-- 上传资源dialog -->
    <el-dialog title="查看图片" :visible.sync="dialogFormUploadImg" width="1100px">
        <div class="padding20" style="text-align: center;">
            <img :src="dialogFormUploadImgSrc" alt="" max-width="1000px">
        </div>
    </el-dialog>
</div>
<!-- import common js-->
<script th:src="@{/js/custom/callrecord/download.js?v=1.0.0}"></script>
<div th:include="_footer_include :: #jsLib"></div>
</body>
<script th:inline="javascript">
var busAreaList=[[${busAreaList}]];//商务大区
var teleDeptList=[[${teleDeptList}]];//电销事业部
var provinceList=[[${provinceList}]];//省份
var projectList=[[${projectList}]];//项目
var fieldList=[[${fieldList}]];//自定义字段
var userFieldList=[[${userFieldList}]];//用户自定义字段
var vistitStoreTypeList=[[${vistitStoreTypeList}]];//签约店型
var payModeItem =[[${payModeItem}]];
var giveTypeList =[[${giveTypeList}]];
var clueVM = new Vue({
        el: '#clueManage',
        data: {
            dialogFormUploadImg: false, //上传资源图片弹框
            dialogFormUploadImgSrc: '', //上传资源图片弹框
            showReviewImagesDialog:false,
            tableDataC1: [],//文件记录
            paginationShow: false,
            isShow:false,
        		searchForm: {
  	       		busAreaId: '',
  	       		busGroupId: '',
  	       		busSaleId: '',
  	       		teleDeptId: '',
  	       		teleGorupId: '',
  	       		teleSaleId: '',
  	       		status: '',
  	       		signProjectId: '',
  	       		cusName: '',
  	       		signProvince: '',
  	       		payType: '',
  	       		phone: '',
  	       		startTime: '',
  	       		endTime: '',
  	       		payStartTime: '',
  	       		payEndTime: '',
  	       		statementNo: '',
  	       		signNo: ''
            },
            viewDoubtForm: {
            	doubtRemark: ''
            },
            count:0,
            dataTable:[],
            allTableColums:[],
            tableColums:[],
            dialogFormVisible: false,
            form: {
	          	type: [],
	          },
            busAreaOptions:busAreaList,
            busGroupOptions:[],
            busSaleOptions:[],
            teleDeptOptions:teleDeptList,
            teleGorupOptions:[],
            teleSaleOptions:[],
            provinceOptions:provinceList,
            projectOptions:projectList,
            statusOptions:[{
            	value:1,
            	name:"未提交对账"
            },{
            	value:2,
            	name:"待处理"
            },{
            	value:3,
            	name:"已对账"
            },{
            	value:4,
            	name:"已结算"
            }],
            payTypeOptions:[{
            	value:1,
            	name:"全款"
            },{
            	value:2,
            	name:"定金"
            },{
            	value:3,
            	name:"追加定金"
            },{
            	value:4,
            	name:"尾款"
            }],
            pager:{
                total: 0,
                currentPage: 1,
                pageSize: 20,
            },
            allocationFormRules: {
          	saleId: [
                  { required: true, message: '请选择商务经理', trigger: 'change' }
              ]
            },
            transferFormRules: {
            	saleId: [
                  { required: true, message: '请选择商务经理', trigger: 'change' }
              ]
            },
            multipleSelection:[],
            viewDoubtVisable:false,
            formLabelWidth: '150px',
            formLabelWidth1: '120px',
            storeForm: {
              busAreaId: '',
              busGroupId: '',
              busSaleId: '',
              teleDeptId: '',
              teleGorupId: '',
              teleSaleId: '',
              status: '',
              signProjectId: '',
              cusName: '',
              signProvince: '',
              payType: '',
              phone: '',
              startTime: '',
              endTime: '',
              payStartTime: '',
              payEndTime: '',
              statementNo: '',
              signNo: ''
            },
            storeId: '',
            scrollTop: 0,
        },
        methods: {
        	  searchTable() {
                var param ={};
                var startTime = this.searchForm.startTime;
                var endTime = this.searchForm.endTime;
                var payStartTime = this.searchForm.payStartTime;
                var payEndTime = this.searchForm.payEndTime;
            	  var vilad=false;
                if(startTime&&endTime&&startTime> endTime){
                	  vilad=true;
                }
                if(payStartTime&&payEndTime&&payStartTime> payEndTime){
                	  vilad=true;
                }
                if(vilad){
                	  this.$message({
                        message: '开始时间不能大于结束时间',
                        type: 'warning'
                    });
                    return;
                }
                param.startTime = startTime;
                param.endTime = endTime;
                param.payStartTime = payStartTime;
                param.payEndTime = payEndTime;
                param.pageSize = this.pager.pageSize;
                param.pageNum = this.pager.currentPage;
                param.busAreaId = this.searchForm.busAreaId;
                param.busGroupId = this.searchForm.busGroupId;
                param.busSaleId = this.searchForm.busSaleId;
                param.status = this.searchForm.status;
                param.signProjectId = this.searchForm.signProjectId;
                param.cusName = this.searchForm.cusName;
                param.teleDeptId = this.searchForm.teleDeptId;
                param.teleGorupId = this.searchForm.teleGorupId;
                param.teleSaleId = this.searchForm.teleSaleId;
                param.signProvince = this.searchForm.signProvince;
                param.payType = this.searchForm.payType;
                param.phone = this.searchForm.phone;
                param.signNo = this.searchForm.signNo;
                param.statementNo = this.searchForm.statementNo;
                
                //列表只查询正常数据，取消删除数据不查询
                //param.delFalg = this.searchForm.delFalg;
                console.info(param);
                axios.post('/financing/reconciliationConfirm/list', param)
                .then(function (response) {
                    var result =  response.data;
                    console.info(result);
                    var table=result.data;
                    clueVM.pager.total =  table.total;
                    clueVM.pager.currentPage = table.currentPage;
                    //查询已结算佣金总计
                    axios.post('/financing/reconciliationConfirm/sumCommissionMoney', param)
                    .then(function (response) {
                          var result =  response.data;
                          console.info(result);
                          clueVM.count= result.data;
                    })
                    .catch(function (error) {
                         console.log(error);
                    });
                    
                    var data= table.data;
                    for(var i=0;i<data.length;i++){
                  	  data[i].status=clueVM.transformStatus(null,null,data[i].status,null);
                  	  data[i].signType=clueVM.transformSignType(null,null,data[i].signType,null);
                  	  data[i].signShopType=clueVM.transformSignShopType(null,null,data[i].signShopType,null);
                  	  data[i].payType=clueVM.transformPayType(null,null,data[i].payType,null);
                  	  data[i].payMode=clueVM.transformPayMode(null,null,data[i].payMode,null);
                  	  data[i].isRemoteSign=clueVM.transformSex(null,null,data[i].isRemoteSign,null);
                  	  if(data[i].ratio){
                    	  data[i].ratio=data[i].ratio+"%";
                  	  }
						data[i].vistitTime = clueVM.dateFormat(null,null,data[i].vistitTime,null);
                    }
                    clueVM.dataTable= data;
                    // 取出存储的id
                    if(!clueVM.paginationShow){
                       if(clueVM.storeId){
                           clueVM.$nextTick(function(){
                              var storage = [];
                              clueVM.dataTable.forEach(function(item, index){
                                  if(item.accountId === clueVM.storeId ){
                                      storage.push(clueVM.dataTable[index]);
                                  }
                              })
                              clueVM.toggleSelection(storage);
                              clueVM.$el.querySelector('.el-table__body-wrapper').scrollTop = clueVM.scrollTop;
                          })
                      }
                    }else{
                      removeSessionStore ("reconciliationConfirmStoreForm");
                      removeSessionStore ("reconciliationConfirmOtherVal");
                    }
                    clueVM.paginationShow = true;
                    clueVM.storeForm = clueVM.searchForm;
                })
                .catch(function (error) {
                     console.log(error);
                });
                
              },
              toggleSelection(rows) { // table select 默认选中fn
                  if (rows) {
                      rows.forEach(row => {
                          this.$refs.multipleTable.toggleRowSelection(row,true);
                      });
                  } else {
                      this.$refs.multipleTable.clearSelection();
                  }
              },
              //选择行
              handleSelectionChange(val) {
                  this.multipleSelection = val;
              },
              handleSizeChange(val) {
                  //下拉框  每页 10,20条切换 调用
                     console.log(`每页 ${val} 条`);
                  this.pageSize = val;
                  this.initTableData(1);
               },
               handleCurrentChange(val) {
                   //点击 页码
                 console.log(`当前页: ${val}`);
                 this.initTableData(val);
               },
               exportFun(){
            	   var param ={};
                   var startTime = this.searchForm.startTime;
                   var endTime = this.searchForm.endTime;
                   var payStartTime = this.searchForm.payStartTime;
                   var payEndTime = this.searchForm.payEndTime;
               	  var vilad=false;
                   if(startTime&&endTime&&startTime> endTime){
                   	  vilad=true;
                   }
                   if(payStartTime&&payEndTime&&payStartTime> payEndTime){
                   	  vilad=true;
                   }
                   if(vilad){
                   	  this.$message({
                           message: '开始时间不能大于结束时间',
                           type: 'warning'
                       });
                       return;
                   }
                   param.startTime = startTime;
                   param.endTime = endTime;
                   param.payStartTime = payStartTime;
                   param.payEndTime = payEndTime;
                   param.pageSize = this.pager.pageSize;
                   param.pageNum = this.pager.currentPage;
                   param.busAreaId = this.searchForm.busAreaId;
                   param.busGroupId = this.searchForm.busGroupId;
                   param.busSaleId = this.searchForm.busSaleId;
                   param.status = this.searchForm.status;
                   param.signProjectId = this.searchForm.signProjectId;
                   param.cusName = this.searchForm.cusName;
                   param.teleDeptId = this.searchForm.teleDeptId;
                   param.teleGorupId = this.searchForm.teleGorupId;
                   param.teleSaleId = this.searchForm.teleSaleId;
                   param.signProvince = this.searchForm.signProvince;
                   param.payType = this.searchForm.payType;
                   param.phone = this.searchForm.phone;
                   param.signNo = this.searchForm.signNo;
                   param.statementNo = this.searchForm.statementNo;
                   param.pageNum='';
                   param.pageSize='';
                   axios.post('/financing/reconciliationConfirm/export',param,{responseType:'blob'})
                   .then(function (response) {
                       console.log(response)
                       var data =  response.data;
                       var fileName = response.headers.filename;
                           saveAs(data,decodeURI(fileName));
                   })
                   .catch(function (error) {
                       console.log(error);
                   }).then(function(){
                	   clueVM.loading=false;
                   });                     	
               	
               },
			//日期数据格式化方法
			dateFormat(row, column, cellValue, index) {
				if (cellValue == undefined) {
					return "";
				}
				return moment(cellValue).format("YYYY-MM-DD");
			},
               //是否转换方法
               transformSex(row, column, cellValue, index) {
                 var text="";
                 if(cellValue=="1"){
                   text="是"
                 }else if(cellValue=="0"){
                   text="否"
                 }
                 return text;
               },
               //签约类型转换方法
               transformSignType(row, column, cellValue, index) {
                 var text="";
                 if(cellValue=="1"){
                   text="一次性全款"
                 }else if(cellValue=="2"){
                   text="先交定金"
                 }
                 return text;
               },
               //付款类型转换方法
               transformPayType(row, column, cellValue, index) {
                 var text="";
                 if(cellValue=="1"){
                   text="全款"
                 }else if(cellValue=="2"){
                   text="定金"
                 }else if(cellValue=="3"){
                   text="追加定金"
                 }else if(cellValue=="4"){
                   text="尾款"
                 }
                 return text;
               },
               //付款方式转换方法
               transformPayMode(row, column, value, index) {
								 var valText="";
								 if(!value){
									 return valText;
								 }
								 var vals = value.split(",");
								 if(payModeItem){
									 for(var j = 0 ; j < vals.length;j++  ){
										 for(var i = 0; i < payModeItem.length ; i++){
											 if(payModeItem[i].value == vals[j]){
												 if(j==0){
													 valText += payModeItem[i].name;
												 }else{
													 valText += ","+payModeItem[i].name;
												 }

											 }
										 }
									 }
								 }
								 return valText;
               },

							transGiveType(row, column, value, index) {
								var text="";
								for(var i=0;i<giveTypeList.length;i++) {
									if(giveTypeList[i].value ==value){
										text = giveTypeList[i].name;
									}
								}
								return text;
							},
               //处理状态转换方法
               transformStatus(row, column, cellValue, index) {
                 var text="";
                 if(cellValue=="2"){
                   text="待处理";
                 }else if(cellValue=="3"){
                   text="已对账";
                 }else if(cellValue=="4"){
                   text="已结算";
                 }else{
                   text="未提交对账";
                 }
                 return text;
               },
               //店型转换方法
               transformSignShopType(row, column, cellValue, index) {
             	  var text="";
             	  if(vistitStoreTypeList){
 	                  for(var i=0;i<vistitStoreTypeList.length;i++){
 	                		if(cellValue==vistitStoreTypeList[i].value){
 	                			text=vistitStoreTypeList[i].name;
 	                		}
 	                	}
             	  }
                   return text;
               },
              
               //对账确认
               reconciliationConfirm() {
           	       var rows = this.multipleSelection;
            	   if(rows.length==0){
                       this.$message({
                          message: '请至少选择一条数据',
                          type: 'warning'
                        });
                       return;
                   }
   	           	   var idList = [];
   	               for(var i=0;i<rows.length;i++){
   	            	  if(rows[i].status!='待处理'){
             		    this.$message({
                            message: '只允许操作待处理状态的数据',
                            type: 'warning'
                          });
                         return;
             	      }
   	            	   var curRow = rows[i];
   	            	   idList.push(curRow.accountId);
   	               }
   	            this.$confirm('确认手工操作为已对账吗？', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                 
                	//对账确认
	            	var param  = {};
   	           	  	param.idList=idList;
                     axios.post('/financing/reconciliationConfirm/reconciliationConfirm',param)
                      .then(function (response) {
                          var data =  response.data;
                          if(data.code=='0'){
                          	clueVM.$message({message:'对账成功',type:'success',duration:1000,onClose:function(){
                              
                          		// clueVM.allocationVisible = false;
                          		// clueVM.searchTable();
                              window.location.href="/financing/reconciliationConfirm/initManager";
                              
                      	    }});
                          }else{
                          	clueVM.$message({
                                  message: "接口调用失败",
                                  type: 'error'
                                }); 
                          }
                          
                      })
                      .catch(function (error) {
                        console.log(error);
                      })
                      .then(function () {
                      	
                      });
                }).catch(() => {
                       
                });
                // 存储选中信息--start
                var clueId=rows[0].accountId;  
                setSessionStore("reconciliationConfirmStoreForm", clueVM.storeForm);
                var otherVal = {
                    "currentPage": clueVM.pager.currentPage,
                    "clueId": clueId,
                    "scrollTop": clueVM.$el.querySelector('.el-table__body-wrapper').scrollTop
                }
                setSessionStore("reconciliationConfirmOtherVal", otherVal);
                // 存储选中信息--end
	            	
               },
               //结算确认
               settlementConfirm() {
            	   var rows = this.multipleSelection;
            	   if(rows.length==0){
                       this.$message({
                          message: '请至少选择一条数据',
                          type: 'warning'
                        });
                       return;
                   }
   	           	   var idList = [];
   	               for(var i=0;i<rows.length;i++){
   	            		if(rows[i].status!='已对账'){
             		    this.$message({
                            message: '只允许操作已对账状态的数据',
                            type: 'warning'
                          });
                         return;
             	      }
   	            	   var curRow = rows[i];
   	            	   idList.push(curRow.accountId);
   	               }
                   
                  // 存储选中信息--end
   	            this.$confirm('确认手工操作为已结算吗？', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {

                	//结算确认
	            	var param  = {};
   	           	  	param.idList=idList;
                     axios.post('/financing/reconciliationConfirm/settlementConfirm',param)
                      .then(function (response) {
                          var data =  response.data;
                          if(data.code=='0'){
                          	clueVM.$message({message:'结算成功',type:'success',duration:1000,onClose:function(){
                              
                          		// clueVM.allocationVisible = false;
                          		// clueVM.searchTable();
                              window.location.href="/financing/reconciliationConfirm/initManager";
                               
                      	    }});
                          }else{
                          	clueVM.$message({
                                  message: "接口调用失败",
                                  type: 'error'
                                }); 
                          }
                          
                      })
                      .catch(function (error) {
                        console.log(error);
                      })
                      .then(function () {
                      	
                      });
                }).catch(() => {
                       
                });
                // 存储选中信息--start
                  var clueId=rows[0].accountId;  
                  setSessionStore("reconciliationConfirmStoreForm", clueVM.storeForm);
                  var otherVal = {
                      "currentPage": clueVM.pager.currentPage,
                      "clueId": clueId,
                      "scrollTop": clueVM.$el.querySelector('.el-table__body-wrapper').scrollTop
                  }
                  setSessionStore("reconciliationConfirmOtherVal", otherVal);
                
               },
               changeTeleDept(selectedValue){//电销事业部
                   this.clearTeleDeptList();
                   if(!selectedValue){
                       return;
                   }
                   var param ={};
                   param.id = selectedValue;
                   axios.post('/organization/organization/queryTeleGroupListByParentId', param)
                   .then(function (response) {
                         var result =  response.data;
                         var table=result.data;
                         clueVM.teleGorupOptions= table;
                   })
                   .catch(function (error) {
                        console.log(error);
                   });
               },
               changeTeleGroup(selectedValue){//改变电销组
                   this.clearTeleGroupList();
                   if(!selectedValue){
                       return;
                   }
                   var param ={};
                   param.id = selectedValue;
                   axios.post('/organization/organization/queryTeleSaleByOrgId', param)
                   .then(function (response) {
                         var result =  response.data;
                         var table=result.data;
                         clueVM.teleSaleOptions= table;
                   })
                   .catch(function (error) {
                        console.log(error);
                   });
               },
               clearTeleDeptList(){
                   this.teleGorupOptions=[];
                   this.searchForm.teleGorupId='';
                   this.clearTeleGroupList();
                   
               },
               clearTeleGroupList(){
                    this.teleSaleOptions=[];
                    this.searchForm.teleSaleId='';
               },
               changeBusArea(selectedValue){//改变商务大区
                   this.clearBusAreaList();
                   if(!selectedValue){
                       return;
                   }
                   var param ={};
                   param.id = selectedValue;
                   axios.post('/organization/organization/queryBusGroupListByParentId', param)
                   .then(function (response) {
                         var result =  response.data;
                         var table=result.data;
                         clueVM.busGroupOptions= table;
                   })
                   .catch(function (error) {
                        console.log(error);
                   });
               },
               changeBusGroup(selectedValue){//改变商务组
                   this.clearBusGroupList();
                   if(!selectedValue){
                       return;
                   }
                   var param ={};
                   param.id = selectedValue;
                   axios.post('/organization/organization/queryBusManagerByOrgId', param)
                   .then(function (response) {
                         var result =  response.data;
                         var table=result.data;
                         clueVM.busSaleOptions= table;
                   })
                   .catch(function (error) {
                        console.log(error);
                   });
               },
               clearBusAreaList(){
                   this.busGroupOptions=[];
                   this.searchForm.busGroupId='';
                   this.clearBusGroupList();
                   
               },
               clearBusGroupList(){
                    this.busSaleOptions=[];
                    this.searchForm.busSaleId='';
               },
               viewDoubt(row) {
                   // 查看疑意
                   clueVM.viewDoubtVisable = true;
                   clueVM.viewDoubtForm.doubtRemark = row.doubtRemark;
               },
               confirmColumn(){
                 	//处理用户选择的列
                 	console.info(this.form.type);
                 	if(this.form.type.length==0){
               		this.$message({
                           message: "请至少保留一列",
                           type: 'error'
                         }); 
               		return;
               	}
                 	this.dialogFormVisible = false;
                 	var customerShowColun = [];
                 	var customerColumn = this.form.type;
                 	customerColumn.sort(this.sortNumber);//对选择的列排序
                 	var idList=[];
                 	for(var i=0;i<customerColumn.length;i++){
                 		var curItem = customerColumn[i];
                 		var itemArr = curItem.split("_");
                 		var obj = {};
                 		obj.fieldCode=itemArr[1];
                 		obj.displayName=itemArr[2];
                 		obj.width=itemArr[4];
                 		customerShowColun.push(obj);
                 		idList.push(itemArr[3])
                 	}
                 	this.tableColums = customerShowColun;
                 	var param ={};
                   param.fieldIdList = idList;
                   param.menuCode = "financing:reconciliationConfirmManager";
                   console.info(param);
                   if(idList.length!=0){
   	                axios.post('/customfield/customField/saveUserField', param)
   	                .then(function (response) {
   	                	
   	                })
   	                .catch(function (error) {
   	                     console.log(error);
   	                });
                   }
                 },
                 initColumn(){
                 	//初始化table 列 和 用户自定义列
                 	this.allTableColums = fieldList;
                 	if(userFieldList.length!=0){
                 		var type=[];
                     	for(var i=0;i<userFieldList.length;i++){
                     		type.push(userFieldList[i].sortNum+'_'+userFieldList[i].fieldCode+'_'+userFieldList[i].displayName+'_'+userFieldList[i].fieldId+'_'+userFieldList[i].width)
                    	}
   	              	this.form.type = type;
   	              	this.confirmColumn();
                 	}else{
                 		var type=[];
                     	for(var i=0;i<fieldList.length;i++){
                     		type.push(fieldList[i].sortNum+'_'+fieldList[i].fieldCode+'_'+fieldList[i].displayName+'_'+fieldList[i].id+'_'+fieldList[i].width)
                    	}
   	              	this.form.type = type;
   	              	this.confirmColumn();
                 	}
                 	
                },
                sortNumber(a,b) {
                    //对数组中元素，按照数字 从小到大 排序
                    return a.split("_")[0] - b.split("_")[0];
                },
                toogleClick(){
                    if(this.isShow){
                        this.isShow=false
                    }else{
                        this.isShow=true
                    }          
                },
                down(){
             	   var rows = this.multipleSelection;
             	   if(rows.length ==0){
                        this.$message({
                           message: '请选择数据',
                           type: 'warning'
                         });
                        return;
                    } else if(rows.length>1){
                        this.$message({
                           message: '请选择一条数据进行下载结算单',
                           type: 'warning'
                         });
                        return;
                    } 
             	   var status = rows[0].status;
             	   if( status =="驳回商务" || status =="未提交对账" ){
             		   this.$message({
                            message: "未提交对账不允许下载结算单",
                            type: 'warning'
                          });
                         return;
             	   }
             	   window.location.href="/financing/balanceaccount/downBalanceAccount?payDetailId="+rows[0].payId;
                },
            showReviewImageClick(row) {
                var param = {};
                param.signId = row.signId;
                axios.post('/businesssign/findFileBySignId', param).then(function (response) {
                    clueVM.tableDataC1 = response.data.data;
                    clueVM.showReviewImagesDialog = true;
                })  .catch(function (error) {
                    console.log(error);
                });

            },
            handleOperateFn(index, row) { //上传资源"查看图片,下载录音"

                if (row.fileType == 'mp3'|| row.fileType == 'mp4' || row.fileType == 'wav' || row.fileType == 'wma'|| row.fileType == '3gpp' || row.fileType == 'm4a' ||row.fileType == 'ape'|| row.fileType == 'midi' || row.fileType == 'amr'|| row.fileType == 'MP3'|| row.fileType == 'MP4' ||row.fileType == 'WAV' || row.fileType == 'WMA'|| row.fileType == '3GPP' || row.fileType == 'M4A' ||row.fileType == 'APE'|| row.fileType == 'MIDI' || row.fileType == 'AMR') {
                    var x = new XMLHttpRequest();
                    x.open("GET", row.filePath, true);
                    x.responseType = 'blob';
                    x.onload = function (e) {
                        download(x.response, row.fileName, "audio/mp3");
                    };
                    x.send();
                } else {
                    this.dialogFormUploadImgSrc = row.filePath;
                    this.dialogFormUploadImg = true;
                }

            },
        },


        created(){
            console.info("create method");
            // 进入页面判断有是否有存储值
            if(!this.paginationShow){
                var storeVal = getSessionStore("reconciliationConfirmStoreForm");
                var otherVal = getSessionStore("reconciliationConfirmOtherVal");
                if(storeVal && otherVal){
                    this.searchForm = storeVal;
                    this.$set(this.pager,"currentPage",otherVal.currentPage);
                    this.storeId = otherVal.clueId;
                    this.scrollTop = otherVal.scrollTop;
                }
            };
            // 取页数存储
            var localVal=localStorage.getItem('allChangePageSize')?parseInt(localStorage.getItem('allChangePageSize')):'';
            if(localVal){this.pager.pageSize = localVal;}
            
            this.initColumn();
            this.searchTable();
           
        },
        mounted(){
           console.info("mounted method");
           document.getElementById('clueManage').style.display = 'block';
        }
    })
    
</script>
</html>